class Solution {
    static const int MOD=1e9+7;
public:
    int numTilings(int n) {
        int dp[1100][4]={0};
        dp[0][3]=1;
        for(int i=1;i<=n;i++)
        {
            dp[i][0]=dp[i-1][3];
            dp[i][1]=(dp[i-1][2]+dp[i-1][0])%MOD;
            dp[i][2]=(dp[i-1][1]+dp[i-1][0])%MOD;
            dp[i][3]=((dp[i-1][3]+dp[i-1][1])%MOD+(dp[i-1][2]+dp[i-1][0])%MOD)%MOD;
        }
        return dp[n][3];
    }
};
